package md.mru.backend.core.service;

import md.mru.backend.common.BaseDtoMapper;
import md.mru.backend.core.domains.administration.Group;
import md.mru.backend.core.domains.administration.UserGroup;
import md.mru.backend.core.dtos.GroupDto;
import md.mru.backend.core.repositories.UserGroupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sergiu.marin
 * @since 16.04.2014.
 */
@Service
public class AdministrationService {

    @Autowired
    @Qualifier(value = "dtoMapper")
    private BaseDtoMapper mapper;
    @Autowired
    private UserGroupRepository userGroupRepository;


    public List<GroupDto> getGroups() {
        List<UserGroup> groups = userGroupRepository.findAll();
        return mapper.mapList(groups, GroupDto.class);
    }

}
